<?php
// Fill up array with error info
$fname="First name is required";
$lname="Last name is required";
$gpa_format="Invalid format (e.g. 3.7, 2.85)";
$format="Invalid format";


//get the q parameter from URL
$q=$_GET["q"];
$p=$_GET["p"];
switch($p)
{
    case 'gpa':
        if(!preg_match("/^[0-9]{1}+.[0-9]{1,2}+$/",$q)){echo $gpa_format;return;}
        else{echo "";return;}
        break;
    case 'fname':
        if(!preg_match("/^[a-zA-Z]+$/",$q)){echo $format;return;}
        else{echo "";return;}
        break;
    case 'lname':
        if(!preg_match("/^[a-zA-Z]+$/",$q)){echo $format;return;}
        else{echo "";return;}
        break;
}
?>